package com.yuanchu.order.client;

import com.yuanchu.common.utils.R;
import com.yuanchu.order.entity.YoshopGoodsEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @version: 1.0
 * @Author: adan
 * @description:
 * @date: 2024-01-24 11:55
 */
@FeignClient(value = "yuanchu-goods", fallbackFactory = FeignGoodsServiceClientFallbackFactory.class)
public interface FeignGoodsClient {

    /**
     * 查询商品图片id
     * @param goodsId
     * @return
     */
    @GetMapping("/goods/image")
    Integer queryGoodsImage(@RequestParam("goodsId") Integer goodsId);

    /**
     * 查询商品信息
     * @param goodsId
     * @param goodsSkuId
     * @return
     */
    @GetMapping("/goods/cart")
    YoshopGoodsEntity queryGoodsInfo(@RequestParam("goodsId") Integer goodsId, @RequestParam("goodsSkuId") String goodsSkuId);

    /**
     * 查询商品库存
     * @param goodsId
     * @param goodsSkuId
     * @return
     */
    @GetMapping("/goods/stock/num")
    Integer queryGoodsStockNum(@RequestParam("goodsId") Integer goodsId, @RequestParam("goodsSkuId") String goodsSkuId);

    /**
     * 减少商品库存
     * @param goodsId
     * @param goodsSkuId
     * @param num
     * @return
     */
    @PostMapping("/goods/stock/decr")
    R decrStockNum(@RequestParam("goodsId") Integer goodsId,
                   @RequestParam("goodsSkuId") String goodsSkuId,
                   @RequestParam("num") Integer num);
}
